<template id="new_try">
    <div class="try_m">
        <div class="new_try_top">
            <img src="../image/blue_da.png" alt="" @click="get_tui()">
            <h4>领取新品试吃赠品</h4>
        </div>
        <div class="try_list_1">
            <div class="try_bu_mmg_1" v-for="(item,index) in data">
                <div class="try_li_st_1">
                    <div class="try_x_m_1"><img class="img_l1"  :src="item.thumb" alt="" ></div>
                    <div class="try_x_right_1">
                        <h2 >{{item.name}}</h2>
                        <p >{{item.goods_share}}</p>
                        <div class="try_Select_price_1">
                            <span >您分享朋友圈成功</span>
                            <span v-if="item.is_use"><time @click="get_user_trial(item.id,item.trial_id)">去领取</time></span>
                        </div>
                    </div>
                </div>
            </div>

        </div>
               <p style="height: 1rem;"></p>
       <!--    <p class="new_try_foot" @click="addCartList()">一键领取新品试吃赠品</p> -->
    </div>
</template>
<script>
    export default{
        name: 'new_try',
        data() {
            return {
                data:[],
            }
        },
        mounted:function () {
            let H=$(window).height();
            $('.try_m').height(H);
           

           //获取往期试吃
           let info  = [];
           info['c'] = 'Member';
           info['m'] = 'trial_user_list';
           info['type'] = 'show' ;
           this.GLOBAL.getApi(this,info);

        },
        methods:{
            get_Release:function(){
                this.$router.push('/Release')
            },
            get_tui:function(){
                window.history.go(-1);
            },
            get_user_trial(goods_id,trial_id){
               let info  = [];
               info['c']    = 'Member';
               info['m']    = 'check_user_trial';
               info['id']   = trial_id;

                let url  = this.GLOBAL.BaseUrl+'/mobile/api/index.php';
                let Data = this.GLOBAL.dataParam(info);

                this.$ajax.post(url,Data).then((res) => {
                    let temp = res.data;
                    if(temp.code == 200){
                        this.GLOBAL.addCart(this,goods_id,1,trial_id);
                        //跳转购物车
                        this.$router.push('/shop');
                    }else{
                        this.GLOBAL.center_error(this,temp);   

                    }  
                })     
            },
        },

    };

</script>
<style>
    .new_try_foot{
        width:100%;
        height:0.8rem;
        line-height:0.8rem;
        text-align:center;
        color:#ffffff;
        font-size:0.3rem;
        background:#2eaffc;
        position:fixed;
        bottom:0;
        left:0;
    }
    /*3*/
    .try_list_1 .try_bu_mmg_1:last-of-type{
        border-bottom:0;
    }
    .try_bu_mmg_1{
        height:1.95rem;
        width:100%;
        border-bottom:0.01rem solid #f0f0f0;
        padding-top:0.34rem;
    }
    .try_li_st_1{
        height:1.95rem;
        width:5.95rem;
        margin:0 auto;
        display:flex;
        /*   flex-wrap: wrap;*/
        justify-content:flex-start;
        /*  border-bottom:0.01rem solid #f0f0f0;*/
    }
    .try_Select_price_1{
        height:0.68rem;
        position:relative;
        top:0;
    }
    .try_Select_price_1 span:nth-of-type(2){
        display:block;
        height:0.42rem;
        width:1.34rem;
        position:absolute;
        color:#ffffff;
        font-size:0.28rem;
        line-height:0.42rem;
        text-align:center;
        border-radius:0.2rem;
        background: -webkit-linear-gradient(left, #7cceff , #2fb0fc); /* Safari 5.1 - 6.0 */
        background: -o-linear-gradient(right, #7cceff, #2fb0fc); /* Opera 11.1 - 12.0 */
        background: -moz-linear-gradient(right,  #7cceff, #2fb0fc); /* Firefox 3.6 - 15 */
        background: linear-gradient(to right, #7cceff, #2fb0fc); /* 标准的语法（必须放在最后） */
        top:-0.3rem;
        right:0;

    }
    .try_Select_price_1 span:nth-of-type(1){
        display:block;
        color:#fc1dac;
        font-size:0.24rem;
        width:2rem;
        height:0.68rem;
        line-height:0.68rem;
    }
   /* .try_Select_price_1 strong{
        font-size:0.24rem;
    }*/
    /* .try_Select_price img{
         display:block;
         position:absolute;
         top: -0.08rem;
         right:0.2rem;
         height:0.6rem;
         width:0.6rem;
     }*/
    .try_x_m_1{
        /* flex:1;*/
        height:1.95rem;
        width:2.12rem;
    }
    .try_x_m_1 img{
        display:block;
        width:1.66rem;
        height:1.66rem;
        border-radius:0.1rem;
        margin:0 auto;
    }
    .try_x_right_1{
        height:1.75rem;
        width:3.84rem;
        /* flex: 1;*/
        padding-top:0.2rem;
    }
    .try_x_right_1 h2{
        height:0.42rem;
        color:#4a4a4a;
        font-size:0.28rem;
        line-height:0.25rem;
        font-weight:normal;
    }
    .try_x_right_1 p{
        height:0.35rem;
        color:#bababa;
        font-size:0.22rem;
        line-height:0.35rem;
    }
    .try_list_1{
        min-height:2.3rem;
        width:100%;
       /* border-bottom:0.1rem solid #f5f4f2;*/
    }
    /*1*/
    .new_try_top{
        height:0.74rem;
        width:100%;
         border-bottom:1px solid #f0f0f0;
        position:relative;
        background:#ffffff;
    }
    .new_try_top img{
        height:0.36rem;
        width:0.36rem;
        display:block;
        position:absolute;
        left:0.25rem;
        top:0.2rem;
    }
    .new_try_top h4{
        height:0.74rem;
        color:#2eaffc;
        font-size:0.3rem;
        line-height:0.74rem;
        text-align:center;
        font-weight:normal;
    }
</style>
